<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2873：光之大陆</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">光之大陆</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">光之大陆</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                光之大陆                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：256MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div style="text-indent: 21pt"><span style="font-size: 12pt">在光之大陆的土地上，各种势力盘根错节。来自光之峡谷的精灵，来自黑暗森林的亡灵，来自古老东方的人类共同生活在一起。善于打造装置的矮人，善于发明的侏儒，隐匿于山林的巨人也坚守着属于自己的领土。这些种族之间关系错综复杂，构成了极其庞大的关系网络。大魔法师小</span><span style="font-size: 12pt">P</span><span style="font-size: 12pt">想要研究其中的种族关系。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">两个物种之间可以是盟友，也可以不是盟友，如果</span><span style="font-size: 12pt">a1,a2..an</span><span style="font-size: 12pt">满足</span><span style="font-size: 12pt">ai</span><span style="font-size: 12pt">和</span><span style="font-size: 12pt">ai+1</span><span style="font-size: 12pt">是盟友，且</span><span style="font-size: 12pt">an</span><span style="font-size: 12pt">和</span><span style="font-size: 12pt">a1</span><span style="font-size: 12pt">是盟友，则他们构成了一个联盟。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">由于光之大陆正处于微妙的和平之中。所以一个合理的物种关系应满足如下条件</span><span style="font-size: 12pt">:</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">1</span><span style="font-size: 12pt">、对于任意两个物种</span><span style="font-size: 12pt">A,B,</span><span style="font-size: 12pt">都存在一个序列</span><span style="font-size: 12pt">A,a1,a2..an,B,</span><span style="font-size: 12pt">使得任意相邻两个种族是盟友</span><span style="font-size: 12pt">(</span><span style="font-size: 12pt">注意</span><span style="font-size: 12pt">A,B</span><span style="font-size: 12pt">不一定是盟友</span><span style="font-size: 12pt">)</span><span style="font-size: 12pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">2</span><span style="font-size: 12pt">、对于任意两个联盟</span><span style="font-size: 12pt">Sa,Sb,</span><span style="font-size: 12pt">都不存在一个物种既参加了联盟</span><span style="font-size: 12pt">Sa</span><span style="font-size: 12pt">，又参加了联盟</span><span style="font-size: 12pt">Sb</span><span style="font-size: 12pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">小</span><span style="font-size: 12pt">P</span><span style="font-size: 12pt">想知道，大陆上的</span><span style="font-size: 12pt">N</span><span style="font-size: 12pt">个种族一共有多少种可能的结盟关系，由于结果可能很大，你只需要输出答案</span><span style="font-size: 12pt">mod M</span><span style="font-size: 12pt">的值。</span></div>
<div style="text-indent: 21pt">&nbsp;</div></p><hr/><h3>输入格式</h3><p><div style="text-indent: 21pt"><span style="font-size: 12pt">一行两个正整数：</span><span style="font-size: 12pt">N,M</span><span style="font-size: 12pt">（含义如题所述）</span></div></p><hr/><h3>输出格式</h3><p><div style="text-indent: 21pt"><span style="font-size: 12pt">一个整数：</span><span style="font-size: 12pt">ans</span><span style="font-size: 12pt">表示方案</span><span style="font-size: 12pt">mod M</span><span style="font-size: 12pt">的值</span></div></p><hr/><h3>样例输入</h3><pre>4 1000000</pre><hr/><h3>样例输出</h3><pre>31</pre><hr/><h3>提示</h3><p><p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="font-size: 12pt; mso-fareast-font-family: 华文细黑"><font face="Calibri">100%</font></span><span style="font-size: 12pt; font-family: 华文细黑; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri">测试点保证</span><span lang="EN-US" style="font-size: 12pt; mso-fareast-font-family: 华文细黑"><font face="Calibri"> n &lt;= 200, m &lt;= 1000000<o:p></o:p></font></span></p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2873" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2873" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>